package org.example.boot.mybatis.test;

import org.example.boot.mybatis.bean.Stu;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.boot.mybatis.mapper.StuMapper;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;
import java.util.Scanner;

@Slf4j
@SpringBootTest
public class App {
    @Resource
    private StuMapper mapper;

    @Test
    public void a() {
        List<Stu> list = mapper.find();
        for (Stu stu : list) {
            log.info("stu:{}",stu);
        }
    }

    @Test
    public void b() {
        Stu stu = new Stu();
        stu.setName("小华");
        stu.setSex("男");
        stu.setAge(18);
        stu.setTel("13991642660");
        stu.setScores("88");
        stu.setSchool("西安石油");
        boolean b= mapper.save(stu);
        log.info("b:{}",b);
        a();
    }

    @Test
    public void c() {
        Stu stu = new Stu();
        stu.setId(5);
        stu.setName("王五");
        boolean b= mapper.update(stu);
        log.info("b:{}",b);
    }

    @Test
    public void d() {
        boolean b=mapper.delete(3);
        log.info("b:{}",b);
        a();
    }

}
